<!-- 综合管理侧边栏 -->
<style lang="less">
.nav {
  min-width: 159px;
}
</style>

<style lang="less" scope>
.multiple-nav {
  > .nav {
    > .ivu-menu {
      > .ivu-menu-item {
        color: #ffffff;
        > span {
          font-weight: 700;
        }
        &:hover {
          background: linear-gradient(to right, #0072ff, #3ac0ff) !important;
        }
      }
      > .ivu-menu-item.ivu-menu-item-active.ivu-menu-item-selected {
        background: linear-gradient(to right, #0072ff, #3ac0ff) !important;
      }
    }
  }
}
</style>


<template>
  <div class="multiple-nav"
       v-if="show">
    <i-col span="2"
           class="nav">
      <Menu theme="dark"
            width="auto"
            @on-select="clickFn"
            accordion>
        <template v-for="v in navItem">
          <Submenu v-if="v.title!=='公文管理'"
                   :name="v.name"
                   :key='v.name'>
            <template slot="title">
              <div class="iconfont navIcon"
                   :class="v.icon"></div>
              <span>{{v.title}}</span>
            </template>
            <Menu-item v-for="i in v.children"
                       :key="i.link"
                       @click="clickFn(i.link)"
                       style="cursor:pointer"
                       :name="i.link">
              <Icon type="ios-paper" />{{i.title}}
            </Menu-item>
          </Submenu>
          <Menu-item v-else
                     :key="v.link"
                     @click="clickFn(v.link)"
                     style="cursor:pointer;"
                     :name="v.link">
            <Icon type="ios-paper" />
            <span>{{v.title}}</span>
          </Menu-item>
        </template>
        <!-- <Submenu :name="v.name"
                 v-for="v in navItem"
                 :key='v.name'>
          <template slot="title">
            <div class="iconfont navIcon"
                 :class="v.icon"></div>
            <span>{{v.title}}</span>
          </template>
          <Menu-item v-for="i in v.children"
                     :key="i.link"
                     @click="clickFn(i.link)"
                     style="cursor:pointer"
                     :name="i.link">{{i.title}}</Menu-item>
        </Submenu> -->
        <template v-if="!types"
                  v-for="i in navItem2">
          <Menu-item v-if="i.title!=='资料管理'"
                     :key="i.link"
                     @click="clickFn(i.link)"
                     style="cursor:pointer;padding: 14px 24px;position: relative;z-index: 1;background: #102860;text-align: center"
                     :name="i.link"> {{i.name}}</Menu-item>
          <Menu-item v-else
                     :key="i.link"
                     @click="clickFn(i.link)"
                     style="cursor:pointer;"
                     :name="i.link">
            <Icon type="ios-paper" />
            <span>{{i.title}}</span>
          </Menu-item>
        </template>

      </Menu>
    </i-col>
  </div>
</template>


<script>
import storage from 'good-storage';
export default {
  data() {
    return {
      navItem: [],
      show: true,
      navItem2: [
        // {
        //   name: '资料管理',
        //   link: 'data',
        // },
        {
          title: '资料管理',
          name: '资料管理',
          icon: 'icon-thing',
          link: 'data',
        },
      ],
      active: '',
      open: [],
    };
  },
  methods: {
    clickFn(name) {
      if (this.types) {
        if (name == 'data-chart') {
          this.$router.push('/aiPicture');
        } else {
          this.$router.push(`/home/data/${name}`);
        }
      } else {
        this.$router.push(`/home/multiple/${name}`);
      }
    },
    showNav() {
      let data = JSON.parse(this.getKey('sideNav2'));
      this.navItem = data;
    },
    hideNav() {
      this.show = false;
    },
  },
  mounted() {
    setTimeout(() => {
      $('.navIcon').siblings('i').remove();
    }, 50);
    if (this.types) {
      this.navItem = [
        {
          title: '资讯管理',
          name: '1',
          icon: 'icon-zixun',
          children: [
            {
              title: '治水动态',
              link: 'flood',
              name: '1-1',
            },
            {
              title: '工作简报',
              link: 'flood2',
              name: '1-2',
            },
            {
              title: '政策管理',
              link: 'policy',
              name: '1-3',
            },
            {
              title: '通知通告',
              link: 'notice',
              name: '1-4',
            },
          ],
        },
        {
          title: '河湖管理',
          name: '2',
          icon: 'icon-river',
          children: [
            // {
            //   title: '一张图',
            //   link: 'data-chart',
            //   name: '2-1',
            // },
            {
              title: '河道综合管理',
              link: 'river',
              name: '2-2',
            },
            {
              title: '湖泊水库管理',
              link: 'lake',
              name: '2-3',
            },
            {
              title: '河长牌管理',
              link: 'board',
              name: '2-4',
            },
          ],
        },
        {
          title: '统计分析',
          name: '3',
          icon: 'icon-tongji',
          children: [
            {
              title: '河长巡河统计',
              link: 'user-count',
              name: '3-1',
            },
            {
              title: '事件统计',
              link: 'report-count',
              name: '3-2',
            },
            {
              title: '考核统计',
              link: 'assessment-count',
              name: '3-3',
            },

            {
              title: '河长牌统计',
              link: 'borad-count',
              name: '3-4',
            },
            {
              title: '河长考核统计',
              link: 'userAss-count',
              name: '3-6',
            },
            {
              title: '巡查发现问题考核统计',
              link: 'patrol-problem-count',
              name: '3-7',
            },
            // {
            //   title: '巡河次数统计表',
            //   link: 'patrol-times-count',
            //   name: '3-8',
            // },
            // {
            //   title: '综合考核统计',
            //   link: 'patrol-count',
            //   name: '3-5',
            // },
            // },
            // {
            //   title: '排污口统计',
            //   link: 'outfall-count',
            //   name: '3-5'
            // }
          ],
        },
        {
          title: '巡查管理',
          name: '4',
          icon: 'icon-xuncha',
          children: [
            {
              title: '河长日志',
              link: 'chief-log',
              name: '4-1',
            },
            {
              title: '巡河记录(事件)',
              link: 'patrol',
              name: '4-2',
            },
            // {
            //   title: '巡河结果',
            //   link: 'chref-complete',
            //   name: '4-3',
            // },
            {
              title: '巡河规则',
              link: 'patrol-rule',
              name: '4-4',
            },
          ],
        },
        {
          title: '部门协同',
          name: '5',
          icon: 'icon-dep',
          children: [
            {
              title: '水质数据',
              link: 'water-quality',
              name: '5-1',
            }
          ],
        },
        {
          title: '待办事项',
          name: '6',
          icon: 'icon-thing',
          children: [
            {
              title: '河流事件',
              link: 'wechat',
              name: '6-1',
            },
            {
              title: '意见反馈',
              link: 'option',
              name: '6-2',
            },
            // {
            //   title: '公文管理',
            //   link: 'document',
            //   name: '6-3',
            // },
            {
              title: '重大项目',
              link: 'major-project',
              name: '6-4',
            },
          ],
        },
        {
          title: '公文管理',
          name: '6-3',
          icon: 'icon-thing',
          link: 'document',
        },
      ];

      // 只开放给市级（即没有area）
      let department = JSON.parse(storage.session.get('department'));
      if (!department[0].area) {
        // 统计分析
        let patrol = {
          title: '综合考核统计',
          link: 'patrol-count',
          name: '3-5',
        };

        let patrol_table = {
          title: '巡河次数统计表',
          link: 'patrol-times-count',
          name: '3-8',
        };

        // 部门协同-水质数据(市河长办)
        let water = {
          title: '水质数据(市河长办)',
          link: 'water-quality-city',
          name: '5-1',
        }

        this.navItem.forEach(item => {
          if (item.title === '统计分析') {
            item.children.splice(item.children.length - 1, 0, patrol);
            item.children.splice(item.children.length - 1, 0, patrol_table);
          }
          if (item.title === '部门协同') {
            item.children.push(water)
          }
        });
      }

    } else {
      this.navItem = [
        {
          title: '系统管理',
          name: '1',
          icon: 'icon-xitongguanli',
          children: [
            {
              title: '河长办管理',
              link: 'department',
              name: '1-1',
            },
            {
              title: '用户管理',
              link: 'user',
            },
            {
              title: '职能部门管理',
              link: 'function',
            },
            {
              title: '职能用户',
              link: 'function-user',
            },
          ],
        },
        {
          title: '综合配置',
          name: '2',
          icon: 'icon-zonghepeizhi',
          children: [
            {
              title: '节假日管理',
              link: 'vacation',
            },
            {
              title: '水质标准管理',
              link: 'water-standard',
            },
          ],
        },
        {
          title: '考核标准管理',
          name: '3',
          icon: 'icon-kaohebiaozhunguanli',
          children: [
            {
              title: '考核标准管理',
              link: 'ass-stand',
            },
            {
              title: '报告任务管理',
              link: 'task',
            },
          ],
        },
        {
          title: '系统权限设置',
          name: '4',
          icon: 'icon-xitongquanxianshezhi',
          children: [
            {
              title: '系统角色',
              link: 'role',
            },
          ],
        },
        {
          title: '日志',
          name: '5',
          icon: 'icon-riqi',
          children: [
            {
              title: '工作日志',
              link: 'userlog',
            },
            {
              title: '短信日志',
              link: 'msg-log',
            },
          ],
        },
        {
          title: '更多功能',
          name: '6',
          icon: 'icon-gengduogongneng',
          children: [
            {
              title: '预案管理',
              link: 'plan',
            },
            {
              title: '公告管理',
              link: 'notice-manage',
            },
            {
              title: '泵闸站管理',
              link: 'gate-pump',
            },
            {
              title: '排污口管理',
              link: 'outfall',
            },
          ],
        },
        {
          title: '关于本系统',
          name: '7',
          icon: 'icon-guanyubenxitong',
          children: [
            {
              title: '事件处理流程',
              link: 'system?type=thing',
            },
            {
              title: '常见问题以及解决方式',
              link: 'system?type=question',
            },
          ],
        },
        {
          title: '操作指引',
          name: '8',
          icon: 'icon-caozuozhiyin',
          children: [
            {
              title: '河长巡河操作手册',
              link: 'system?type=chref-patrol',
            },
            {
              title: '河长处理事件app流程',
              link: 'system?type=chref-thing',
            },
            {
              title: '用户使用手册',
              link: 'system?type=chref-use',
            },
          ],
        },
      ];
      let level = storage.session.get('level');
      if (level == '3') {
        this.navItem[0].children.splice(2, 2);
      }
    }
  },
  created() {
    this.$bus.on('hideSideNav', this.hideNav);
  },
  beforeDestroy() {
    this.$bus.off('hideSideNav', this.hideNav);
  },
  props: {
    types: {
      type: Boolean,
      default: true,
    },
  },
};
</script>
